<% extends "common/msui.html" %>
<% block title %>地址编辑<% endblock %>
<% block body %>
<div class="page" id="address-edit" ms-controller="my_edit">
  <header class="bar bar-nav">
    <a class='button button-link button-nav pull-right' style='margin-right:5px' ms-click='content_update'><span>完成</span></a>
    <a class="button button-link button-nav pull-left back" href="/mshop/products" >
      <span class="icon icon-left"></span>
      返回
    </a>
    <h1 class="title">{{partner.name}}</h1>
  </header>

  <div class="content address-edit-content" >
    <ul>
      <li><div><span >名称</span><input type='text' ms-duplex='partner.name' readonly /></div></li>
      <li><div><span >手机</span><input type="number" ms-duplex='partner.mobile' /></div></li>
      <li><div><span >电话</span><input type='number' ms-duplex='partner.phone' /></div></li>
      <li><div><span >邮件</span><input type='text' ms-duplex='partner.email' /></div></li>
    </ul>
  </div>

  <script type="application/javascript" >
    $(function() {
      var partner_id = ${partner_id|safe}

      var sync_content = function() {
        $.ajax({
          url: '/mshop/my/info/get',
          data: {'partner_id': partner_id},
          success: function(e) {
            my_edit_vm.partner = JSON.parse(e);
          },
          type: 'GET',
          async: true,
        });
      };

      sync_content();

      var my_edit_vm = avalon.define({
        $id: 'my_edit',
        partner: {},
        content_update: function() {
          $.ajax({
            url: '/mshop/my/info/update',
            data: {partner_id: partner_id, value: JSON.stringify({mobile: my_edit_vm.partner.mobile, phone: my_edit_vm.partner.phone, email: my_edit_vm.partner.email})},
            type: 'POST',
            success: function(e) {
              window.history.back();
            },
            async: true,
          });
        },
      });

      avalon.scan();
    });
  </script>

<% endblock %>
</div>